select max(use_date), min(use_date), count(*) from bank

select * from bank_types

delete from bank
go
delete from budget
go

select count(*) from bank
go
select count(*) from budget
go

select * from bank where use_date > '2009-06-01'

select * from bank b1
where abs(DATEDIFF(use_date, account_date)) > 20

select * from bank where abs( amount )> 12000

select * from bank where interest_date<= '2000-12-31'



select * from bank_types
select * from bank where use_date > '20100101'

select b.date, b.text, b.amount, ba.name, bank.name, b.is_remainder from budget b, budget_accounts ba, bank_accounts bank
where ba.id = b.budget_account_id and b.bank_account_id = bank.id


select year(date), budget_accounts.name, budget_account_id, bank_accounts.name, sum(amount), count(*) 
from budget , budget_accounts, bank_accounts
where date (date) >= '2007-01-01' -- and date (date) < '2009-01-01'
and budget.budget_account_id = budget_accounts.id
and budget.bank_account_id = bank_accounts.id
group by year(date), bank_account_id, budget_account_id, budget_accounts.name, bank_accounts.name
order by budget_account_id, date


select * from budget where date >= '2010-01-01'
order by date

update budget set is_matched= 'N' where date >= '2010-01-01'

update budget set is_remainder= 'Y' where date >= '2010-01-01'

select * from bank where 
text like "%lomme%"
order by use_date


update budget set is_matched='Y', is_permament = 'N', is_remainder = 'N', date = '2009-12-31'
where id in (
 81467  ,
 81492  ,
 81623  ,
 82041)


select date, budget_accounts.name, budget_account_id, bank_accounts.name, text, amount
from budget , budget_accounts, bank_accounts
where
--date (date) >= '2008-01-01' and date (date) < '2009-01-01'
and budget_account_id = 109
and budget.budget_account_id = budget_accounts.id
and budget.bank_account_id = bank_accounts.id


select * from budget 
where lower(text) like "%apotek%"
order by date


select * from budget where date >= '2007-12-27' and date < '2008-01-01'
order by date

select created_date, count(*) from budget
group by created_date 


select * from budget where created_date = '2010-07-16 17:01:08'
and budget_account_id = 109
order by date

update budget set date = DATE_ADD(date, INTERVAL 2 year)
where created_date = '2010-07-16 16:53:51'

delete from budget where created_date >= '2010-07-16 16:59:30'

select year (date) , count(*) from budget
group by year(date)


select * from budget where date >= '2010-01-01'
and text like "%hybel%"
order by date

update budget set is_matched = 'N' where date >= '2010-01-01'
update budget set text = 'Lommepenger Fredrik' where text = 'OK: Lommepenger Fredrik' and date >= '2010-01-01'


